﻿<?php
//Luu giu dieu kien loc
$v_page = $_SESSION['v_session_page'];
$v_limit_row = $_SESSION['v_session_limit_num_page'];
$v_recordtype_filter = $_SESSION['onegate_current_recordtype'];
$v_current_status = ($arr_single_record['C_CURRENT_STATUS']);
$v_recortype = $arr_single_record['FK_RECORDTYPE'];
$v_detail_status = intval($arr_single_record['C_DETAIL_STATUS']);
$v_staff_id = _get_item_attr_by_id ($_SESSION['arr_all_staff'],$_SESSION['staff_id'],'id');
/*
* VuNH Modified
* date: 13/07/2007
* Content: Neu trang thai hs la 'TRINH_KY' thi khong cho them/xoa tien do
*/
$v_C_CURRENT_STATUS = $arr_single_record['C_CURRENT_STATUS'];

//Kiem tra NSD hien thoi dong vai tro la thu ly chinh doi voi ho so hien thoi va trang thai cua ho so la "DANG_THU_LY" va C_DETAIL_STATUS <>20
if ( (onegate_is_main_handler_for_record($v_staff_id,$v_record_id))&&  $v_current_status == "DANG_THU_LY" && $v_detail_status <> 20){
	$v_is_main_handler_for_record_and_status = 1;
}else{
	$v_is_main_handler_for_record_and_status = 0;
}
// Neu la can bo thu ly chinh va ho so dang o trang thai la "Chuyen co quan co tham quyen giai quyet" thi cho cap nhat tien do cong viec
//vi neu can bo thu ly chinh trinh ho so len cho lanh ky duyet xem xet roi lanh dao chon option "Chuyen co quan co tham quyen giai quyet"
//thi trang thai C_CURRENT_STATUS = "TRINH_KY". Nhu vay neu NSD hien thoi la can bo thu ly chinh va trang thai = 70 thi cho cap nhat tien do cong viec
if(
	(onegate_is_main_handler_for_record($v_staff_id,$v_record_id))
	&& ($v_detail_status == 70)
  ){
  	$v_is_main_handler_for_record_and_status = 1;
  }
// Luu ten style hien thoi
$v_current_style_name = "odd_row";
// Luu ten style tiep theo
$v_next_style_name = "";

$v_code_record = $arr_single_record['C_CODE'];
$v_received_date = _yyyymmdd_to_ddmmyyyy($arr_single_record['C_RECEIVED_DATE']);
$v_appointed_date = _yyyymmdd_to_ddmmyyyy($arr_single_record['C_APPOINTED_DATE']);
$v_handler = $arr_single_record['FK_HANDLER'];
$v_current_status = $arr_single_record['C_CURRENT_STATUS'];
$v_recordtype = $arr_single_record['C_RECORDTYPE_NAME'];	

$v_handler_name =_get_item_attr_by_id($_SESSION['arr_all_staff'],$v_handler ,'name');//Ten can bo thu ly

$v_handle_agency_id = _get_item_attr_by_id($_SESSION['arr_all_staff'],$v_handler,'unit_id');//Ma phong thu ly
$v_handle_agency = _get_item_attr_by_id($_SESSION['arr_all_unit'],$v_handle_agency_id,'name');//Ten phong thu ly
$v_goto_url = "index.php";
?>
<!--bang chua tieu de cua form-->
<table width="100%" cellpadding="0" cellspacing="0">
	<tr class="normal_title">
		<td>
			<?php echo CONST_RATE_RECORD_WORK_TITLE; ?>
			<a id="goto" href="" style=".color:white">#</a>
		</td>
	</tr>
</table>
<!-- bang chua cac tieu thuc loc-->
<table cellpadding="0" cellspacing="0" width="100%" >								
	<tr>
	 	<form action="index.php" name="frm_dsp_all_record_work" method="post">
		<input type="hidden" name="hdn_record_work_id"  value="<?php echo $v_work_id; ?>">
		<input type="hidden" name="hdn_record_id"  value="<?php echo $v_record_id; ?>">
		<input type="hidden" name="hdn_worker_id"  value="<?php echo $v_work_id; ?>">
		<input type="hidden" name="hdn_recordtype_filter" value="<?php echo $v_recordtype_filter; ?>">
		<input type="hidden" name="hdn_list_id"  value="0">
		<input type="hidden" name="fuseaction"  value="">
		<input type='hidden' name='hdn_page' value='<?php echo $v_page;?>'>
		<input type='hidden' name='hdn_record_number_page' value='<?php echo $v_limit_row;?>'>
	</tr>
</table>	
<table width="100%" class="form_table1" border="0" cellpadding="0" cellspacing="0">
	<col width="18%"><col width="32%"><col width="31%"><col width="19%">
	<tr>
		<td colspan="10"><?php echo onegate_show_record_general_info($arr_single_record,$_SESSION['recordtype'],$v_show_link,$p_petition_link_supplyment,$p_rate_of_progress_link,$p_document_link,$p_idea_link,$p_sign_link,$p_approve_link,$p_licensing_link,$v_url_view_update_record_status); ?></td>
	</tr>
	<tr>
		<td colspan="10">		
			<table class="list_table2" width="100%" cellpadding="0" cellspacing="0">
				<col width="5%"><col width="15%"><col width="20%"><col width="40%"><col width="20%">
				<tr class="header">
					<td>#</td>
					<td><?php echo CONST_RECORD_DATE_LABEL; ?></td>
					<td><?php echo CONST_RECORD_WORKTYPE_LABEL; ?></td>
					<td><?php echo CONST_RECORD_RESULT_LABEL; ?></td>
					<td><?php echo CONST_RECORD_WORKER_LABEL; ?></td>
				</tr>
			</table>	
			<!--
			<div style="overflow: auto; width: 100%; height:<?php echo _CONST_HEIGHT_OF_LIST?>;padding-left:0px;margin:0px">
			!-->
			<table class="list_table2" width="100%" cellpadding="0" cellspacing="0">
				<col width="5%"><col width="15%"><col width="20%"><col width="40%"><col width="20%">
				<?php 
				if ($v_count_record_work>0){
					for($row_index = 0;$row_index< $v_count_record_work ;$row_index++){
						$v_work_id = $arr_record_work[$row_index]['PK_RECORD_WORK'];
						$v_worker =$arr_record_work[$row_index]['FK_WORKER'];
						$v_worktype = $arr_record_work[$row_index]['C_WORKTYPE_NAME'];
						$v_work_date_code = _yyyymmdd_to_ddmmyyyy($arr_record_work[$row_index]['C_DATE']);									
						$v_work_result = _replace_bad_char($arr_record_work[$row_index]['C_RESULT']);
						$v_file_name = $arr_record_work[$row_index]['C_FILE_NAME'];
						$v_system_worktype = $arr_record_work[$row_index]['C_SYSTEM_WORKTYPE'];
						if (!$v_system_worktype)
							if($v_worker == $v_staff_id){
								$v_disabled="";
							}else{
								$v_disabled=" disabled";	
							}	
						else $v_disabled=" disabled";
			
						$v_worker_name =_get_item_attr_by_id($_SESSION['arr_all_staff'],$v_worker ,'name');
						
						$v_file_url = trim(CONST_URL_PATH_FROM_ROOT) . $v_file_name;
						$v_file_url = "javascript:filename_onclick('T_ONEGATE_RECORD_WORK', 'PK_RECORD_WORK', 'C_FILE_NAME', 'C_FILE_CONTENT'," . strval($v_work_id) . ",'" . $v_file_url ."');" ;
						
						if ($v_status==1){$v_status=CONST_AF_STATUS_APPROVE; }
						else if ($v_status==2){$v_status=CONST_AF_STATUS_APPROVED; }
						else if ($v_status==3){$v_status=CONST_AF_STATUS_REFUSE;}
						$v_url = "row_onclick(" . "document.forms(0).hdn_record_work_id"  .  "," . $v_work_id . "," . "'DISPLAY_SINGLE_RECORD_WORK','" . $v_goto_url . "')";
						if ($v_current_style_name == "odd_row"){
							$v_current_style_name = "round_row";
						}else{
							$v_current_style_name = "odd_row";
						}?>	
						<tr class="<?php echo $v_current_style_name ?>"> 
							<td align="center">
								<input type="checkbox" name="chk_work_id" value="<?php echo $v_work_id; ?>" <?php echo $v_disabled;?>>
							</td>
							<td align="center" onClick="<?php echo $v_url;?>">
								<a name="<?php echo $v_work_id;?>"><?php echo $v_work_date_code;?></a>
							</td>	
							<td align="left" onClick="<?php echo $v_url;?>">
								<a name="<?php echo $v_work_id;?>"><?php echo $v_worktype;?></a>
							</td>	
							<td align="left" onClick="<?php echo $v_url;?>">
								<a name="<?php echo $v_work_id;?>"><?php echo $v_work_result."<br>";?></a>
								<a href="<? echo $v_file_url; ?>" class="normal_link"><? echo $v_file_name;?></a>
							</td>	
							<td align="center" onclick="<?php echo $v_url ;?>">
								<a name="<?php echo $v_work_id;?>"><?php echo $v_worker_name; ?></a>
							</td>
						</tr><?php 
					}	
				}
				if ($v_current_style_name == "odd_row"){
					$v_next_style_name = "round_row";
				}else{
					$v_next_style_name = "odd_row";
				}
				echo _add_empty_row($v_count_record_work,_CONST_NUMBER_OF_ROW_PER_LIST,$v_current_style_name,$v_next_style_name,5);
				?>
			</table>
			<!--
			</div>
			!-->
		</td>
	</tr>
	<tr height="5px">
		<td>&nbsp;</td>
	</tr>
</table>
<table align="center">
	<tr><td height="5"></td></tr>
	<tr>
		<td><?php
			if ( ($v_is_granted_update) 
					||($v_is_main_handler_for_record_and_status) 
					//Kiem tra NSD hien thoi co quyen duoc cap nhat tien do cong viec khong?
					|| (onegate_is_permission_update_rate_of_progress_for_recordtype($v_staff_id,0,$_SESSION["recordtype"]))
				){?>
				<?php // --- Begin - VuNH 130707
				if(($v_C_CURRENT_STATUS != 'TRINH_KY') && ($v_C_CURRENT_STATUS != 'DANG_THU_LY'))
				{?>
						<input type="button" value="<?php echo _CONST_ADD_BUTTON; ?>" name="btn_add" class="normal_button" onClick="btn_add_onclick(document.forms(0).hdn_record_work_id, 'DISPLAY_SINGLE_RECORD_WORK')">
						<input type="button" value="<?php echo _CONST_DELETE_BUTTON; ?>" name="btn_delete" class="normal_button" onClick="btn_delete_onclick(document.frm_dsp_all_record_work.chk_work_id,document.frm_dsp_all_record_work.hdn_list_id,'DELETE_RECORD_WORK')"><?php
				}// --- End - VuNH 130707
			}if ($_ISA_CURRENT_MODUL_CODE == "CUSTOMER"){?>
				<input type="button" value="<?php echo _CONST_BACK_BUTTON; ?>" name="btn_back" class="normal_button" onClick="btn_back_onclick('<?php echo $_GO_BACK?>');"><?php
			}?>
		</td>
	</tr>
</table>
</form>
